package cn.itsource.order.controller;

import cn.itsource.order.domain.TUserAddress;
import cn.itsource.order.service.IUserAddressService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import java.util.List;

@RestController
@RequestMapping("/useraddress")
public class UserAddressController {

    @Autowired
    private IUserAddressService addressService;

    @GetMapping
    public List<TUserAddress> findAllByUserId(HttpServletRequest request){
        //当前登录的user_id从token到redis查出来
        String token = request.getHeader("token");
        return addressService.findAllByUserId(token);
    }
}
